{{include file="Manage/header.html"}}
<body class="regi_body">
	<div class="regi_header">
		<a href="javascript:">培育计划申报</a>
	</div>
	<div class="register">
		<div class="bule_bg">
			<div>用户注册</div>
		</div>
		<form method="post" onsubmit="return false">
			<div class="content">
				<table>
					<tr>
						<td>身份</td>
						<td>
							<ul class="dowebok">
								<li><input id="radio3" type="radio" name="type" data-labelauty="老师" value="1"></li>
								<li><input id="radio4" type="radio" name="type" data-labelauty="学生" checked value="2"></li>
							</ul>
						</td>
					</tr>
					<tr>
						<td>姓名</td>
						<td><input type="text" name="username"></td>
						<td id="username">请填写真实姓名</td>
					</tr>
					<tr id="num">
						<td>学号</td>
						<td><input type="text" name="params[student_id]"></td>
						<td id="student_id">请填写学号</td>
					</tr>
					<tr>
						<td>性别</td>
						<td>
							<ul class="dowebok">
								<li><input id="radio1" type="radio" name="sex" data-labelauty="男" checked value="0"></li>
								<li><input id="radio2" type="radio" name="sex" data-labelauty="女" value="1"></li>
							</ul>
						</td>
					</tr>
					<tr>
						<td>所在院系</td>
						<td>
							<select name="college" id="change_college">
								<option value="" selected="true">请选择所在院系...</option>
								{{if $result}}
								{{foreach from=$result item=val key=key}}
									<option value="{{$val.id}}">{{$val.title}}</option>
								{{/foreach}}
								{{/if}}
							</select>
						</td>
						<td id="college">请选择所在院系</td>

					<tr id="major">
						<td>专业</td>
						<td>
							<select name="class" id="change_class">
								<option value="">请选择专业...</option>
							</select>
						</td>
						<td id="class">请选择专业</td>
					</tr>
					<tr>
						<td>邮箱</td>
						<td><input type="text" name="email"></td>
						<td id="email">请填写安全邮箱</td>
					</tr>
					<tr>
						<td>密码</td>
						<td><input type="password" name="password"></td>
						<td id="password">密码由6-20位的英文字母、数字和特殊符号组成</td>
					</tr>
					<tr>
						<td>确认密码</td>
						<td><input type="password" name="password2"></td>
						<td id="password2">请再次填写一遍密码，以辅助检测密码输入是否正确</td>
					</tr>
					<tr>
						<td>手机号</td>
						<td><input type="text" name="number"></td>
						<td id="number">请填写常用手机号码</td>
					</tr>
					<tr class="get_code">
						<td>验证码</td>
						<td>
							<input type="text" id="code" tab = 'register'>
							<button id="sms">获取短信验证码</button>
						</td>
					</tr>
				</table>
					<button onclick="register();">注册</button>
				<div class="go_login"><a href="index.php?app=Login&act=index">已有账号？去登录</a></div>
			</div>
		</form>
	</div>
	<script>

		//tab切换
        $(function(){
            $("#radio3").click(function () {
                if ($(this).prop("checked")) {
                    $("#num").hide();
                    $("#major").hide();
                }
            });
            $("#radio4").click(function () {
                if ($(this).prop("checked")) {
                    $("#num").show();
                    $("#major").show();
                }
            });
            $(':input').labelauty();
        })

		{{include file="Manage/user.js"}}

		//注册提交
		function post(){
        	var params = $("form").serialize();
            $.post('{{"index.php?app=Login&register_code"|URL}}',params,function(result){
                if(result.statusCode=='200'){
                    ui.success(result.message);
                    setTimeout(function(){
                        var url = "{{$smarty.const.__PROJECT__}}Login/index";
                        document.location.href = url;//登录后跳转页面
                    },1000);
                }else if(result.statusCode=='300') $("#"+result.message.name+"").html(result.message.message).css('color','#E9686B');
            },'json');
		}

		//院系改变
		$("#change_college").change(function(){
			var id = $(this).val();
			$.get('{{"index.php?app=Login&act=getclass"}}',{'id':id},function(result){
				if(result.statusCode == '200'){
					$("#change_class").html(result.message).trigger("chosen:updated");
				}
			},'json');
			if(id !='')
				$(this).parent().next().html("<svg height='20px' width='20px' aria-hidden='true'><use xlink:href='#icon-tongguo'></use></svg>");
			else
				$(this).parent().next().html('请选择院系').css('color','#E9686B');
		})

		//专业改变
		$("#change_class").change(function(){
			var id = $(this).val();
			if(id !='')
				$(this).parent().next().html("<svg height='20px' width='20px' aria-hidden='true'><use xlink:href='#icon-tongguo'></use></svg>");
			else
				$(this).parent().next().html('请选择院系').css('color','#E9686B');
		})

	</script>
{{include file="Manage/footer.html"}}